
<?php	
	
	require_once('../../lib/'.'BaseDir.inc.htm');	
	
	require_once (EIU_CLASS.'IOClass.htm');	
	require_once (EIU_CLASS.'BlockClass.htm');	
	require_once (EIU_CLASS.'InvoiceClass.htm');	
	require_once (EIU_CLASS.'Category.htm');	
	require_once (EIU_CLASS.'CusClass.htm');	
	
	set_time_limit(30);
	//Define the max number of row on a page	
	
		$data["dataSearch"]["TimeStart"] = date("h:i:s:u");		
		
		$invoiceObj = new io_class();
		//Lấy danh sách Invoice
		$InvcNo="";
		$SuppID="";
		$SuppName="";
		$FromDate="0000-00-00";
		$ToDate="2100-01-01";
		$Description="";
		$invoiceList = $invoiceObj->getInvoiceList($InvcNo,$SuppID,$SuppName,$FromDate,$ToDate,$Description);
		
		//Xuất ra danh sách invoice
		$i = 0;
		while($invoiceList[$i])
		{
			$data["dataSearch"]["ioList"][$i]["InvcID"] = $invoiceList[$i]->{"InvcID"};
			$data["dataSearch"]["ioList"][$i]["InvcNo"] = $invoiceList[$i]->{"InvcNo"};
			$data["dataSearch"]["ioList"][$i]["SuppName"] = $invoiceList[$i]->{"SuppName"};
			$data["dataSearch"]["ioList"][$i]["Description"] = $invoiceList[$i]->{"Description"};
			$data["dataSearch"]["ioList"][$i]["InvcDate"] = $invoiceList[$i]->{"InvcDate"};
			$i++;
		}
		
			
		//Lấy danh sách category
		$catObj = new category();
		$catList = $catObj->getCategoriesList();
		
		$i = 0;
		while($catList[$i])
		{
			$data["dataSearch"]["catList"][$i]["CATCode"] = $catList[$i]->{"CATCode"};
			$data["dataSearch"]["catList"][$i]["CATName"] = $catList[$i]->{"CATName"};
			$data["dataSearch"]["catList"][$i]["hasBarQRCode"] = $catList[$i]->{"hasBarQRCode"};		
			$i++;
		}
	
		//Lấy danh sách khách hàng
		$cusObj = new cus_class();
		$cusList = $cusObj->getCusList();
		$i = 0;
		while($catList[$i])
		{
			$data["dataSearch"]["cusList"][$i]["CusID"] = $cusList[$i]->{"CusID"};
			$data["dataSearch"]["cusList"][$i]["ComName"] = $cusList[$i]->{"ComName"};
			$data["dataSearch"]["cusList"][$i]["ComAddress"] = $cusList[$i]->{"ComAddress"};
			$data["dataSearch"]["cusList"][$i]["ComTel"] = $cusList[$i]->{"ComTel"};
			$data["dataSearch"]["cusList"][$i]["ComFax"] = $cusList[$i]->{"ComFax"};
			$data["dataSearch"]["cusList"][$i]["ParentID"] = $cusList[$i]->{"ParentID"};
			$data["dataSearch"]["cusList"][$i]["BankName"] = $cusList[$i]->{"BankName"};
			$data["dataSearch"]["cusList"][$i]["BankCN"] = $cusList[$i]->{"BankCN"};
			$data["dataSearch"]["cusList"][$i]["BankAcc"] = $cusList[$i]->{"BankAcc"};
			$data["dataSearch"]["cusList"][$i]["ParentName"] = $cusList[$i]->{"ParentName"};			
			$i++;
		}
	
	$data["dataSearch"]["TimeFinish"] = date("h:i:s:u");	
	$json = json_encode($data["dataSearch"]);
	
	echo $json;	
	
?>